<?php

namespace addons\zzuser\controller\api;

use app\common\controller\Api;
use think\Cache;
use think\Validate;

class TestSms extends Api
{
    protected $noNeedLogin = 'index';
    protected $noNeedRight = 'index';

    public function index()
    {
        $config = get_addon_config('zzuser');
        if ($config['test_is'] == 'yes') {
            $validate = new Validate();
            if (!$validate->check(input(), [
                'mobile' => 'require|regex:1\d{10}',
            ])) {
                $this->error($validate->getError());
            }
            $mobile = input('mobile');
            $sms    = Cache::get($mobile);
            $this->success('', $sms);
        }
    }
}
